{// 引入标签库 }
<tagLib name="fanwe" />
<include file="Public:header" />
<load href="__TMPL__ThemeFiles/Js/jquery.js" />
<load href="__TMPL__ThemeFiles/Js/jquery.json.js" />
<load href="__TMPL__ThemeFiles/Js/tabs.js" />
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/calendar.php?lang=zh-cn" ></script>
<load href='__TMPL__ThemeFiles/Js/calendar/calendar.css' />
<load href='__TMPL__ThemeFiles/Js/auction.js' />
<script type="text/javascript">
var lang_ids = '{$lang_ids}';
var lang_names = '{$lang_names}';
var DIY_URL = '{%DIY_URL}';
</script>
<div id="main" class="main" >
	<div class="content">
		<div class="title">{$Think.lang.ADD_DATA} [ <a href="{:u($module_name.'/index')}">{$Think.lang.BACK_LIST}</a> ]</div>
		<div id="result" class="result none"></div>
		<form method='post' id="form" name="form" action="{:u('Auction/update')}"  enctype="multipart/form-data">
			<ul class="conf_btns">
				<li>基本信息</li>
				<li>详细说明</li>
				<li>关联城市</li>
			</ul>
			<div class="conf_tabs">
			<table cellpadding=0 cellspacing=0 class="conf_table dataEdit" >
			<tr>
				<td class="tRight">竞拍名称：</td>
				<td class="tLeft" ><fanwe:textbox name="name" class="bLeftRequire" /></td>
			</tr>
			<tr>
				<td class="tRight">竞拍图片：</td>
				<td class="tLeft" >
					<input type="file" name="img" class="bLeft" /><if condition="$vo['img'] neq ''"><span id="delectImg">&nbsp;&nbsp;<a href="__ROOT__{$vo.img}" target="_blank">{%VIEW}</a>&nbsp;&nbsp;<a href="javascript:;" onclick="deleteImg()">{%_DELETE_DATA}</a></span></if>
				</td>
			</tr>
			<tr>
				<td class="tRight">竞拍类型：</td>
				<td class="tLeft" >
					<if condition="$vo['auction_type'] eq 0">
					广告位
					<elseif condition="$vo['auction_type'] eq 1"/>
					团购排序
					</if>
				</td>
			</tr>
			<if condition="$vo['auction_type'] eq 0">
			<tr class="auction_type auction_type_0" <if condition="$vo['auction_type'] eq 1">style="display:none;"</if>>
				<td class="tRight">广告位：</td>
				<td class="tLeft" >
					<select name="rec_id" class="bLeftRequire">
					<foreach name="adv_positions" item="adv_position" >
					<option value="{$adv_position.id}" <if condition="$vo['rec_id'] eq $adv_position['id']">selected="selected" </if>>{$adv_position.name}</option>
					</foreach>
					</select>
					&nbsp;可加广告数量：<input type="text" name="rec_attr[ad_num]" class="bLeft" value="{$rec_attr.ad_num}" style="width:80px;" />
				</td>
			</tr>
			<tr>
				<td class="tRight">{$Think.lang.ADV_TYPE}：</td>
				<td class="tLeft" >
					<select name="rec_attr[ad_type]" class="bLeft">
						<option value="0" <if condition="$rec_attr['ad_type'] eq 0">selected="selected" </if>>不限制</option>
						<option value="1" <if condition="$rec_attr['ad_type'] eq 1">selected="selected" </if>>{$Think.lang.ADV_TYPE_1}</option>
						<option value="2" <if condition="$rec_attr['ad_type'] eq 2">selected="selected" </if>>{$Think.lang.ADV_TYPE_2}</option>
						<option value="3" <if condition="$rec_attr['ad_type'] eq 3">selected="selected" </if>>{$Think.lang.ADV_TYPE_3}</option>
					</select>
					&nbsp;指定到：<input type="text" name="rec_data" class="bLeft" value="{$vo.rec_data}" style="width:80px;" />
				</td>
			</tr>
			<elseif condition="$vo['auction_type'] eq 1"/>
			<tr class="auction_type auction_type_1" <if condition="$vo['auction_type'] eq 0">style="display:none;"</if>>
				<td class="tRight">团购排序：</td>
				<td class="tLeft" >
					<input type="text" name="rec_data" class="bLeft" value="{$vo.rec_data}"/>
					&nbsp;<span style="color:#f00;">在团购列表中的显示排序</span>
				</td>
			</tr>
			</if>
			<tr>
				<td class="tRight">计费类型：</td>
				<td class="tLeft" >
					<if condition="$vo['billing_type'] eq 0">
					点击付费
					<elseif condition="$vo['billing_type'] eq 1"/>
					固定费用
					</if>
				</td>
			</tr>
			<tr>
				<td class="tRight">开始时间：</td>
				<td class="tLeft" >
					<input type="text"  name="begin_time" id="begin_time"  class="bLeft" value="{:toDate($vo['begin_time'])}" />
					<input type="button" name="btn_begin_time" id="btn_begin_time" onclick="return showCalendar('begin_time', '%Y-%m-%d %H:%M:%S', false, false, 'btn_begin_time');" value="{$Think.lang.SELECT}" class="button"/>
				</td>
			</tr>
			<tr>
				<td class="tRight">结束时间：</td>
				<td class="tLeft" >
					<input type="text"  name="end_time" id="end_time"  class="bLeft" value="{:toDate($vo['end_time'])}"/>
					<input type="button" name="btn_end_time" id="btn_end_time" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M:%S', false, false, 'btn_end_time');" value="{$Think.lang.SELECT}" class="button"/>
				</td>
			</tr>
			<tr>
				<td class="tRight">有效期：</td>
				<td class="tLeft" >
					<if condition="1 eq $vo['auction_status'] and $vo['validity_begin_time'] lt $time and $vo['user_id'] gt 0">
					{:toDate($vo['validity_begin_time'])}
					<input type="hidden"  name="validity_begin_time" value="{:toDate($vo['validity_begin_time'])}"/>
					<else/>
					<input type="text"  name="validity_begin_time" id="validity_begin_time"  class="bLeft" style="width:120px;" value="{:toDate($vo['validity_begin_time'])}"/>
					<input type="button" name="btn_validity_begin_time" id="btn_validity_begin_time" onclick="return showCalendar('validity_begin_time', '%Y-%m-%d %H:%M:%S', false, false, 'btn_validity_begin_time');" value="{$Think.lang.SELECT}" class="button"/>
					</if>
					&nbsp;至&nbsp;
					<if condition="1 eq $vo['auction_status'] and ($vo['validity_end_time'] gt 0 AND $vo['validity_end_time'] lt $time) and $vo['user_id'] gt 0">
					{:toDate($vo['validity_end_time'])}
					<input type="hidden"  name="validity_end_time" value="{:toDate($vo['validity_end_time'])}"/>
					<else/>
					<input type="text"  name="validity_end_time" id="validity_end_time"  class="bLeft"  style="width:120px;" value="{:toDate($vo['validity_end_time'])}"/>
					<input type="button" name="btn_validity_end_time" id="btn_validity_end_time" onclick="return showCalendar('validity_end_time', '%Y-%m-%d %H:%M:%S', false, false, 'btn_validity_end_time');" value="{$Think.lang.SELECT}" class="button"/>
					</if>
				</td>
			</tr>
			<if condition="1 eq $vo['auction_status'] && $vo['user_id'] gt 0">
			<tr>
				<td>&nbsp;</td>
				<td>
					<span style="color:#f00;">当竞拍被成功拍得后，只能修改未开始的有效期开始时间和未结束的有效期结束时间</span>
				</td>
			</tr>
			</if>
			<tr>
				<td class="tRight">起拍价：</td>
				<td class="tLeft" >
					<input type="text" name="base_price" class="bLeftRequire ratioInput" value="{$vo.base_price}" />
					&nbsp;=&nbsp;<span id="base_price_ec" style="color:#f00;">{:intval($vo['base_price'] * $ratio)}</span>&nbsp;论坛交易币，<span style="color:#f00;">请确保论坛币为正整数，结算时将以整数进行积分结算</span>
				</td>
			</tr>
			<tr>
				<td class="tRight">一口价：</td>
				<td class="tLeft" >
					<input type="text" name="buyout_price" class="bLeft ratioInput" value="{$vo.buyout_price}" />
					&nbsp;=&nbsp;<span id="buyout_price_ec" style="color:#f00;">{:intval($vo['buyout_price'] * $ratio)}</span>&nbsp;论坛交易币，<span style="color:#f00;">请确保论坛币为正整数，结算时将以整数进行积分结算</span>
				</td>
			</tr>
			<tr>
				<td class="tRight">加价幅度：</td>
				<td class="tLeft" >
					<input type="text" name="amplitude" class="bLeftRequire ratioInput" value="{$vo.amplitude}" />
					&nbsp;=&nbsp;<span id="amplitude_ec" style="color:#f00;">{:intval($vo['amplitude'] * $ratio)}</span>&nbsp;论坛交易币，<span style="color:#f00;">请确保论坛币为正整数，结算时将以整数进行积分结算</span>
				</td>
			</tr>
			<if condition="$vo['billing_type'] eq 0">
			<tr>
				<td class="tRight">预付费：</td>
				<td class="tLeft" >
					<input type="text" name="pre_pay" class="bLeft ratioInput" value="{$vo.pre_pay}" />
					&nbsp;=&nbsp;<span id="pre_pay_ec" style="color:#f00;">{:intval($vo['pre_pay'] * $ratio)}</span>&nbsp;论坛交易币，<span style="color:#f00;">请确保论坛币为正整数，结算时将以整数进行积分结算</span>
				</td>
			</tr>
			<tr>
				<td class="tRight">&nbsp;</td>
				<td class="tLeft" ><span style="color:#f00;">用户竞拍时，最低余额限制，竞价成功后，将冻结此设置金额，在以后的点击中扣除</span>
				</td>
			</tr>
			</if>
			<tr>
				<td class="tRight">竞拍状态：</td>
				<td class="tLeft"><label><input type="checkbox" name="auction_status" value="1" <if condition="1 eq $vo['auction_status']">checked="checked"</if>/>已结束</label></td>
			</tr>
			<tr>
				<td class="tRight">竞拍{$Think.lang.SORT}：</td>
				<td class="tLeft"><input type="text" name="sort" class="bLeft" value="{$vo.sort}" /></td>
			</tr>
			<tr>
				<td class="tRight" width="150">热门：</td>
				<td class="tLeft" >
					<label><input type="radio" name="is_hot" value="0" <if condition="0 eq $vo['is_hot']">checked="checked"</if>>否</label>
					<label><input type="radio" name="is_hot" value="1" <if condition="1 eq $vo['is_hot']">checked="checked"</if>>是</label>
				</td>
			</tr>
			<tr>
				<td class="tRight">竞拍描述：</td>
				<td class="tLeft" ><textarea style="width:80%; height:80px;" name="brief">{$vo.brief}</textarea></td>
			</tr>
		</table>
		<table cellpadding="0" cellspacing="0" width=100% class="conf_table dataEdit">
			<tr>
				<td>
					<fanwe:editor  name="desc" type="KindEditor"  style="width:100%;height:300px;visibility:hidden;" />
				</td>
			</tr>
		</table>
		<table cellpadding=0 cellspacing=0 class="conf_table dataEdit" >
			<tr>
				<td class="tLeft">
					<if condition="1 eq $vo['auction_status'] and $vo['validity_begin_time'] lt $time and ($vo['validity_end_time'] eq 0 OR $vo['validity_end_time'] gt $time) and $vo['user_id'] gt 0">
					<div style="line-height:26px; padding:0 8px;">
						推广针对城市：
						<if condition="1 eq $is_all_city">
						全国<input type="hidden" name="is_all_city" value="1" />
						<else/>
						<foreach name="auction_citys" key="ac_py" item="ac_list">
						<foreach name="ac_list" item="ac_item">
						<if condition="1 eq $ac_item['is_city']">
						{$ac_item.name}<input type="hidden" name="auction_city[]" value="{$ac_item.id}" />&nbsp;
						</if>
						</foreach>
						</foreach>
						</if>
						<br/>
						<span style="color:#f00;">当竞拍被成功拍得后，不能在推广有效期内修改针对城市。</span>
					</div>
					<else/>
					<div style="height:26px; line-height:26px; color:#f00; padding:0 8px;">
						设置该竞拍的推广针对那些城市进行，如果针对所有城市，请勾选全国复选框&nbsp;
						<input type="checkbox" name="is_all_city" id="is_all_city" value="1" <if condition="1 eq $is_all_city">checked="checked"</if>/>&nbsp;是否全国
					</div>
					<div id="auction_citys">
						<foreach name="auction_citys" key="ac_py" item="ac_list">
						<dl style="width:100%; float:left; padding:0 8px;margin:0;">
							<dt style="width:100%; float:left; padding:0;margin:0; font-weight:bold; font-size:14px;">{$ac_py}</dt>
							<dd style="width:100%; float:left; padding:10px 0 0 0; margin:0;">
							<foreach name="ac_list" item="ac_item">
								<p style="width:80px; float:left; margin:0 8px 8px 0;">
									<label><input type="checkbox" name="auction_city[]" class="auction_city" value="{$ac_item.id}" isChecked="{$ac_item.is_city}" <if condition="1 eq $ac_item['is_city']">checked="checked"</if> <if condition="1 eq $is_all_city">disabled="disabled"</if>/>&nbsp;{$ac_item.name}</label>
								</p>
							</foreach>
							 </dd>
						</dl>
						</foreach>	
					</div>
					</if>
				</td>
			</tr>
		</table>
		<div style="padding:20px 0 0 130px;">
			<input type="hidden" name="id" value="{$vo.id}" />
			<input type="submit" value="{$Think.lang.SAVE_DATA}"  class="button small">
			<input type="reset" class="button small" onclick="resetEditor()" value="{$Think.lang.RESET_DATA}" >
		</div>
		</div>
		</form>
	</div>
</div>

<script type="text/javascript">
var aid = {$vo.id};
var ratio = {$ratio};
function delectImg()
{
	$.ajax({
		url: APP+"?"+VAR_MODULE+"=Auction&"+VAR_ACTION+"=delectImg",
		cache: false,
		data:{"id":aid},
		success:function(data)
		{
			$("#delectImg").remove();
		}
	});		
}

jQuery(function($){
	$(".ratioInput").keyup(function(){
		var price = parseFloat(this.value);
		if(isNaN(price))
			price = 0;
		
		$("#"+this.name+"_ec").html(price * ratio);
	});
	
	$(".ratioInput").blur(function(){
		var price = parseFloat(this.value);
		if(isNaN(price))
			price = 0;
		$("#"+this.name+"_ec").html(price * ratio);
	});
});
</script>

